/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package br.com.caelum.project.hibernate;

import br.com.caelum.project.model.Produto;
import org.hibernate.cfg.AnnotationConfiguration;
import org.hibernate.Session;
import org.hibernate.SessionFactory;

/**
 *
 * @author dyguilherme
 */
public class HibernateUtil {
	private static SessionFactory factory;

	static{
		AnnotationConfiguration cfg = new AnnotationConfiguration();
		cfg.addAnnotatedClass(Produto.class);
		cfg.configure();
		factory = cfg.buildSessionFactory();
	}

	public Session getSession(){
		return factory.openSession();
	}
}
